﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;

namespace ClassLibrary.DAO
{
    public class TblMenuParrentDAO
    {
        private DBService _db = null;
        public TblMenuParrentDAO(String ConnectionString)
        {
            _db = new DBService(ConnectionString);
        }

        public DataTable InsUp(TblMenuParent menuPa, int mode)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("TblMenuParrent_InsUP",

                    new string[] { "@IDMenuParent", "@MenuParentName", "@ImageURL", "@Mode" },
                    new object[] { menuPa.IDMenuParent, menuPa.MenuParentName, menuPa.ImageURL, mode }, CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable GetAll()
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("select * from TblMenuParent", false, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable GetMenuPa_ByID(int IDParent)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("select * from TblMenuParent where IDMenuParent = @IDMenuPa",
                    new string[] { "@IDMenuPa" }, new object[] { IDParent }, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }
    }
}
